package com.micro.modual.extension;

import com.google.common.base.Joiner;
import com.micro.common.MicroConstant;
import com.micro.common.biz.GeneratorCodeUtil;
import com.micro.common.util.SnowFlakeUtil;
import com.micro.modual.entity.GoodsParameters;
import com.micro.modual.model.bo.goodsparameters.GoodsParametersBO;

import java.util.Date;

/**
 * <h1>商品参数表 延展类</h1>
 *
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:23:27
 */
public class GoodsParametersExtension {

    /**
     * <h2>转换: 商品参数表 新增</h2>
     *
     * @param goodsParametersBO {@link GoodsParametersBO} 商品参数表 新增/修改 请求对象
     * @return {@link GoodsParameters} 商品参数表
     */
    public static GoodsParameters converAddGoodsParameters(GoodsParametersBO goodsParametersBO) {
        GoodsParameters goodsParameters = new GoodsParameters();
        goodsParameters.setId(SnowFlakeUtil.getId());
        goodsParameters.setParamsName(goodsParametersBO.getParamsName());
        goodsParameters.setParamsOptions(Joiner.on(",").join(goodsParametersBO.getParamsOptions()));
        goodsParameters.setParamsSort(goodsParametersBO.getParamsSort());
        goodsParameters.setTemplateCode(goodsParametersBO.getTemplateCode());
        goodsParameters.setCreateTime(new Date());
        return goodsParameters;
    }

    /**
     * <h2>转换: 商品参数表 修改</h2>
     *
     * @param goodsParametersBO {@link GoodsParametersBO} 商品参数表 新增/修改 请求对象
     * @return {@link GoodsParameters} 商品参数表
     */
    public static GoodsParameters converEditGoodsParameters(GoodsParametersBO goodsParametersBO) {
        GoodsParameters goodsParameters = new GoodsParameters();
        goodsParameters.setId(goodsParametersBO.getId());
        goodsParameters.setParamsName(goodsParametersBO.getParamsName());
        goodsParameters.setParamsOptions(Joiner.on(",").join(goodsParametersBO.getParamsOptions()));
        goodsParameters.setParamsSort(goodsParametersBO.getParamsSort());
        goodsParameters.setTemplateCode(goodsParametersBO.getTemplateCode());
        goodsParameters.setUpdateTime(new Date());
        return goodsParameters;
    }
}
